<?php

namespace App\Miya\Tools;

class TqlTool
{
    /**
     * 生成对应目录的模版文件数组
     * @param $view
     * @param $dir
     * @return array
     */
    static public function buildTqlOptions($view, $dir, $type = 'web')
    {
        $blades = glob(base_path(sprintf('%s/%s/%s/*', $view, $type, $dir)));

        $data = [];

        collect($blades)->each(function ($blade) use ($view, $type, $dir, &$data) {
            $filename = basename($blade);
            $tag = sprintf('%s::%s.%s.%s', $view, $type, $dir, explode('.', $filename)[0]);
            $data[$tag] = str_replace([base_path(), '\\'], '', $blade);
        });

        return $data;
    }
}
